package jmine.tec.persist.schema.impl.dialects;

import java.sql.Types;
import java.util.Collections;
import java.util.List;

/**
 * Dialeto utilizado para geração do schema pelo jTec para o banco de dados Oracle10g
 * 
 * @author lundberg
 */
public class PostgreSQLDialect extends AbstractSqlDialect {

    /**
     * Construtor
     */
    public PostgreSQLDialect() {
        super(new org.hibernate.dialect.PostgreSQLDialect());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<String> renderCheckConstraint(String table, String name, int typeCode, String condition) {
        if (Types.BIT == typeCode) {
            return Collections.emptyList();
        } else {
            return super.renderCheckConstraint(table, name, typeCode, condition);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String renderLiteral(int code, String defaultValue) {
        if (Types.BIT == code) {
            if ("0".equals(defaultValue)) {
                return "FALSE";
            } else if ("1".equals(defaultValue)) {
                return "TRUE";
            }
        }
        return super.renderLiteral(code, defaultValue);
    }
}
